﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Xejen.Communication.Test
{
    public class HeartbeatChecker : IHeartbeatChecker
    {
        public Func<bool> RemoteHeartbeatCheck => () =>
        {
            Debug.WriteLine($"本地心跳检测时间：{DateTime.Now.ToString()}");
            byte[] buffer = Guid.NewGuid().ToByteArray();
            var value = BitConverter.ToInt64(buffer, 0);

            return value % 2 == 1;
        };

        public Func<bool> LocalHeartbeatCheck => () =>
        {
            Debug.WriteLine($"远端心跳检测时间：{DateTime.Now.ToString()}");
            byte[] buffer = Guid.NewGuid().ToByteArray();
            var value = BitConverter.ToInt64(buffer, 0);

            return value % 2 == 0;
        };
    }
}
